package servlet.Course;

import bean.Course;
import dao.impl.CourseDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/courseAllServlet")
public class CourseAllServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        CourseDaoImpl dao = new CourseDaoImpl();
        List<Course> course = dao.getCourseAll();
        HttpSession session = req.getSession();
        System.out.println(course);
        session.setAttribute("courseList", course);
        resp.sendRedirect("/course/showCourse.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
